﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;

namespace XmlStudio.ViewModel.Node {
    [Serializable]
    public class XsdAttributeViewModel : XmlAttributeViewModel, IDataErrorInfo {
        private bool required;

        /// <summary>
        /// Gets or sets value indicating whether this attribute is required.
        /// </summary>
        public bool Required {
            get {
                return this.required;
            }

            set {
                this.required = value;
                this.OnPropertyChanged("Required");
            }
        }

        #region IDataErrorInfo Members
        public string Error {
            get { throw new NotImplementedException(); }
        }

        public string this[string columnName] {
            get {
                string result = null;
                if(columnName == "Value") {
                    if(Required && string.IsNullOrEmpty(this.Value)) {
                        result = "Value is required.";
                    }
                }

                return result;
            }
        }
        #endregion
    }
}
